package com.yequan.work;

import java.util.Arrays;
import java.util.List;

/**
 * @author yequan
 * @date 2021/03/30 20:54
 **/
public class ThreeMax {

    public static void main(String[] args) {
        System.out.println(findMin(1, 3, 3));

        System.out.println(findMin(3, 1, 2));

        System.out.println(findMin(3, 2, 1));

        System.out.println(getCacheKey(1, 2, 1, 3));
        System.out.println(getCacheKey(1, 3, 2, 1));
        System.out.println(getCacheKey(1, 1, 3, 2));
    }

    public static String getCacheKey(Integer userId, long rideId1, long rideId2, long rideId3) {
        List<Long> ids = Arrays.asList(rideId1, rideId2, rideId3);
        ids.sort((o1, o2) -> (int) (o1 - o2));
        return String.format("%s-%s-%s-%s", userId, ids.get(0), ids.get(1), ids.get(2));
    }

    private static int max(int a, int b, int c) {
        int max;
        if (a > b) {
            max = a;
        } else {
            max = b;
        }

        if (max < c) {
            max = c;
        }
        return max;
    }

    private static int findMin(int time1, int time2, int time3) {
        int min;
        if (time1 < time2) {
            min = time1;
        } else {
            min = time2;
        }

        if (min > time3) {
            min = time3;
        }
        return min;
    }

}
